package com.jiac.coderunner.entity;

import com.google.common.base.CaseFormat;

import java.util.HashSet;
import java.util.Set;

public class FieldInfo {
    private String columnName;
    private String camelName;
    private String camelUperName;
    private String dataType;
    private boolean isKey;
    private boolean nullAble;
    private String comment;
    private String importCls;

    public String getColumnName() {
        return columnName;
    }

    public String getCamelName() {
        return camelName;
    }
    public void setColumnName(String columnName) {
        this.columnName = columnName;
        this.camelName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL,columnName);
        this.camelUperName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL,columnName);
    }

    public String getCamelUperName(){
        return camelUperName;
    }
    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        switch (dataType) {
            case "varchar" : dataType="String" ;break;
            case "char" : dataType="String" ;break;
            case "text" : dataType="String" ;break;
            case "tinyint" : dataType="Integer" ;break;
            case "smallint" : dataType="Integer" ;break;
            case "mediumint" : dataType="Integer" ;break;
            case "integer" : dataType="Long" ;break;
            case "float" : dataType="Float" ;break;
            case "double" : dataType="Double" ;break;
            case "blob" : dataType="byte[]" ;break;
            case "decimal" : dataType="Bigdecimal" ; this.importCls="java.math.BigDecimal";break;
            case "date" : dataType="Date";this.importCls="java.util.Date";break;
            case "time" : dataType="Date" ;this.importCls="java.util.Date";break;
            case "datetime" : dataType="Date" ;this.importCls="java.util.Date";break;
            case "timestamp" : dataType="Date" ;this.importCls="java.util.Date";break;
            case "year" : dataType="Date" ;this.importCls="java.util.Date";break;
            default: dataType="String";
        }
        this.dataType = dataType;
    }

    public boolean getIsKey() {
        return isKey;
    }

    public void setIsKey(boolean isKey) {
        this.isKey = isKey;
    }

    public boolean getNullAble() {
        return nullAble;
    }

    public void setNullAble(boolean nullAble) {
        this.nullAble = nullAble;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getImportCls(){
        return this.importCls;
    }
}
